﻿using System;
using System.Globalization;
using System.Threading;
using System.Windows;
using Microsoft.Phone.Controls;

namespace SampleApplication
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            // this is all the code you need to show the about page
            NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative));

            // use the "SelectedPivotIndex" to navigate to a certain item index directly,
            // for example when you want to directly show the version history after an update of your app.
            //string url = string.Format("/YourLastAboutDialog;component/AboutPage.xaml?{0}={1}", AboutPage.SelectedPivotItemIndexKey, 1);
            //NavigationService.Navigate(new Uri(url, UriKind.Relative));

            // you can also pre-select an item by its title (please keep in mind that you then need to 
            // dynamically determine the correct item title if you're supporting multiple languages)
            //string url = string.Format("/YourLastAboutDialog;component/AboutPage.xaml?{0}={1}", AboutPage.SelectedPivotItemHeaderKey, "more");
            //NavigationService.Navigate(new Uri(url, UriKind.Relative));

            // for those interested in creating trial-mode apps: you can force the "buy" button to appear with a parameter, too:
            //string url = string.Format("/YourLastAboutDialog;component/AboutPage.xaml?{0}=True", AboutPage.ForceBuyButtonKey)
            //NavigationService.Navigate(new Uri(url, UriKind.Relative));
            // this is helpful if you e.g. use a "lite" version of your app that points to a _different_ full version app in the marketplace
            // (= you're not using the built-in trial mode). See the YLAD documentation for more details on this scenario.
        }

        private void EnglishButton_Click(object sender, RoutedEventArgs e)
        {
            SetCurrentUICulture(new CultureInfo("en-US"));
        }

        private void GermanButton_Click(object sender, RoutedEventArgs e)
        {
            SetCurrentUICulture(new CultureInfo("de-DE"));
        }

        private void AustrianButton_Click(object sender, RoutedEventArgs e)
        {
            SetCurrentUICulture(new CultureInfo("de-AT"));
        }

        private void SetCurrentUICulture(CultureInfo cultureInfo)
        {
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
        }
    }
}